<template>
  <el-card class="avue_height">
    <div style="margin:10px 0px 20px 0px;">
      <template v-for="(item,index) in btn">
        <el-button
          type="primary"
          :key="index"
          @click="handler(index)"
          v-if="permissions.dal_goodstock_add"
        >{{item.title}}</el-button>
      </template>
    </div>
    <avue-crud
      ref="crud"
      style="width:100%"
      :data="loadData"
      :option="tableOption"
      :table-loading="loading"
      @selection-change="selectionChange"
    >
     <template slot-scope="scope" slot="indexLabel">
        <span>{{scope.row.$index+(page.current - 1) * page.size + 1}}</span>
      </template>
      <template slot="menu" slot-scope="scope">
        <el-button
          @click="edit(scope.row)"
          type="text"
          icon="el-icon-edit"
          :disabled="scope.row.disabled"
        >编辑</el-button>
        <el-button
          @click="del(scope.row)"
          type="text"
          icon="el-icon-delete"
          :disabled="scope.row.disabled"
        >删除</el-button>
      </template>
    </avue-crud>
    <template>
      <div style="width:100%;position:relative;height:50px">
        <el-pagination
          :page-sizes="[10, 20,30,40, 50, 100]"
          :pager-count="7"
          :current-page="page.current"
          :page-size="page.size"
          :total="page.total"
          layout="total, sizes, prev, pager, next, jumper"
          style="margin:2% 0;position:absolute;right:1%"
          background
          @size-change="sizeChange"
          @current-change="currentChange"
        ></el-pagination>
      </div>
    </template>
     <el-dialog
      :title="title == 1? '新增':'编辑'"
      :visible.sync="dialogVisible"
      width="40%"
      :destroy-on-close="true"
    >
      <el-form
        :model="ruleForm"
        :rules="rules"
        ref="ruleForm"
        :labelWidth="labelWidth"
        class="demo-ruleForm"
      >
        <el-row :gutter="10">
          <el-col :xs="24" :sm="24">
            <el-form-item label="单位名称：" prop="stockUnitName">
              <el-input
                v-model="ruleForm.stockUnitName"
                placeholder="请输入单位名称"
                @change="lmmcChange"
                maxlength="15"
              />
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogVisible = false">取 消</el-button>
        <el-button type="primary" @click="handleSave()" :loading="loading1" v-if="title">保 存</el-button>
        <el-button type="primary" @click="handleEdit()" :loading="loading1" v-else>修 改</el-button>
      </div>
    </el-dialog>
  </el-card>
</template>

<script src='./index.js'></script>

<style>
</style>